//package com.bcmusic.music.timer;
//
//import com.bcmusic.music.dao.MusicDistributionMapper;
//import com.bcmusic.music.dao.MusicPublicationMapper;
//import com.bcmusic.music.pojo.MusicDistribution;
//import com.bcmusic.music.pojo.MusicPublication;
//import com.bcmusic.music.service.MusicPublicationService;
//import entity.SystemConstants;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.context.annotation.Lazy;
//import org.springframework.data.redis.core.RedisTemplate;
//import org.springframework.scheduling.annotation.EnableScheduling;
//import org.springframework.scheduling.annotation.Scheduled;
//import org.springframework.stereotype.Component;
//import org.springframework.stereotype.Controller;
//import tk.mybatis.mapper.entity.Example;
//
//import java.util.Date;
//import java.util.List;
//import java.util.Set;
//
///**
// * @ClassName : DistrubutionPushTask  //类名
// * @Description : 多线程将符合条件的分发条款放到redis中,后面换cannel //描述
// * @Author : YG  //作者
// * @Date: 2020-11-07 11:22  //时间
// */
//@Component
//@EnableScheduling
//public class DistributionPushTask {
//
//    @Autowired
//    private MusicDistributionMapper musicDistributionMapper;
//
//    @Autowired
//    private RedisTemplate redisTemplate;
//
//    @Scheduled(cron = "*/10 * * * * ?")
//    public void pushDistributionToRedis(){
//        System.out.println("执行啦");
//        Example example=new Example(MusicDistribution.class);
//        Example.Criteria criteria=example.createCriteria();
//        criteria.andEqualTo("validStatus",1);
//        criteria.andGreaterThan("remainNum",0);
////        criteria.andGreaterThanOrEqualTo("allowStartTime",new Date());
//        criteria.andLessThanOrEqualTo("allowStartTime",new Date());
//        criteria.andGreaterThanOrEqualTo("allowEndTime",new Date());
//
//        //排除hash中已经有的
//        Set keys = redisTemplate.boundHashOps(SystemConstants.DISTRIBUTION_PREFIX).keys();
//
//        if(keys!=null && keys.size()>0) {
//            criteria.andNotIn("distributeId", keys);
//        }
//
//        List<MusicDistribution> musicDistributions = musicDistributionMapper.selectByExample(example);
//
//        for(MusicDistribution musicDistribution:musicDistributions)
//        {
//            System.out.println(musicDistribution);
//            redisTemplate.boundHashOps(SystemConstants.DISTRIBUTION_PREFIX).put(musicDistribution.getDistributeId(),musicDistribution);
//        }
//    }
//}
